/*var playlistLayer:MovieClip;
var playModeLayer:MovieClip;
var playFormatLayer:MovieClip;
var playSeekLayer:MovieClip;*/
var timeDisplay:TextField;
var previewFillingMaskBar;
var previewDuration:Number;

var selectedMenu:String;
var selectedMode:String;
// var selectedPlayItem:String;

var playItemList:Array=new Array();
//*// default item temp
	var playItem:Object=new Object();
	playItem.name="Default Reading";
	playItem.sync="sample/syncFile.xml";
	addPlayItem(playItem);
//*/
var currentPlayItemListNum;
var currentFloatingPart:String;
var currentPlayMode:String;

var menuItems:Array=["nowplay", "mode", "format", "seek", "playlist"];

var playerEngineRunning:Boolean;
var localChineseFontArr:Array;
var localFontCount:Number;

function init(param, data, slot)
{
	trace(this._name+".init...");

	Packages.system.Platform.renderPortlet(slot);
	var fmt:TextFormat=new TextFormat();
	for (var i=0; i<menuItems.length; i++)
	{
		fmt.size=14;
		fmt.color=0xffffff;
		fmt.align="center";
		Packages.system.Platform.renderTextStyle(slot, menuItems[i], fmt, 0x000000);
	}
	
	timeDisplay=mlf.gatekeeper.native.Caller.scanElement(slot, "timedisplay");
	displayTimePeriod(timeDisplay, 0, 0);
	var previewFillingBar=mlf.gatekeeper.native.Caller.scanElement(slot, "fillbar");
	previewFillingMaskBar=previewFillingBar.duplicateMovieClip("masker", previewFillingBar._parent.getNextHighestDepth());
	previewFillingBar.setMask(previewFillingMaskBar);

	currentPlayMode="sync";

	var pauseIcon=mlf.gatekeeper.native.Caller.scanElement(slot, "pauseIcon");
	pauseIcon._visible=false;
	var backIcon=mlf.gatekeeper.native.Caller.scanElement(slot, "backIcon");
	backIcon._visible=false;
	/*var selectedBg=mlf.gatekeeper.native.Caller.scanElement(slot, "@selectedBg");
	selectedBg._alpha=0;
	var overBg=mlf.gatekeeper.native.Caller.scanElement(slot, "@overBg");
	overBg._alpha=0;*/
	Packages.system.MLF.addListener("onColorPickerChanged", this);

	playItemList[0].name=Packages.system.MLF.scanDictionary(previewFillingMaskBar, "Platform Guide");
	playItemList[0].sync=Packages.system.Util.getHttpBaseUrl()+"/download?type=2&subtype=1000&uuid=794c4fe2-994c-4206-85fe-728a61bb3747";	// Predefined
	selectedMenu=null;
	pressMenu("_root-Player-main-playlistSpot", null, slot);
	releaseMenu("_root-Player-main-playlistSpot", null, slot);
}

function onColorPickerChanged(obj)
{
	var colorTf=mlf.gatekeeper.native.Caller.scanElement("PlayFormat", "colorInput");
	colorTf.text="0x"+obj.param;
}

function modeInit(param, data, slot)
{
	selectedMode=null;
	pressMode("_root-PlayMode-basic-mode1spot", null, slot);
	releaseMode("_root-PlayMode-basic-mode1spot", null, slot);
}

function changeFloatingVisible(selectedPart:String)
{
	// trace("currentFloatingLayer: "+currentFloatingLayer);
	var selectedLayer=mlf.gatekeeper.native.Caller.scanElement(selectedPart, "basic");
	selectedLayer._visible=true;
	var currentFloatingLayer=mlf.gatekeeper.native.Caller.scanElement(currentFloatingPart, "basic");
	currentFloatingLayer._visible=false;
	currentFloatingPart=selectedPart;
}

function addPlayItem(pItem:Object)
{
	playItemList.push(pItem);
}

function exit(param, data, slot)
{
	Packages.system.MLF.removeListener("onPlayback", this);
	applications.prototype.Logic.run("Stop");
	mlf.mcmanager.SMCManager.popInstance("PlayMode");
	mlf.mcmanager.SMCManager.popInstance("PlayList");
	mlf.mcmanager.SMCManager.popInstance("PlayFormat");
	mlf.mcmanager.SMCManager.popInstance("PlaySeek");
	Packages.components.Scene.enterHomePage(null, null, slot);
}

/*function forward()
{
	trace(this._name+".forward...");
	if (currentPlayMode=="sync" || currentPlayMode=="audio")
	{
		applications.prototype.Logic.run("Play");
	}
	else if (currentPlayMode=="text")
	{
		mlf.mcmanager.MessageAgent.getMessageDispatcher().dispatch({type:"onTxtSync", offset:1});
	}
}

function backward()
{
	trace(this._name+".backward...");
	if (currentPlayMode=="sync" || currentPlayMode=="audio")
	{
		applications.prototype.Logic.run("Pause");
	}
	else if (currentPlayMode=="text")
	{
		mlf.mcmanager.MessageAgent.getMessageDispatcher().dispatch({type:"onTxtSync", offset:-1});
	}
}*/

function mode()
{
	trace(this._name+".mode...");

	var playModeLayer=mlf.gatekeeper.native.Caller.scanElement("PlayMode", "basic");
	if (playModeLayer==null)
	{
		establishPlayMode();
	}
	changeFloatingVisible("PlayMode");
}

function establishPlayMode()
{
	mlf.gatekeeper.native.Caller.MLoader("app/PlayMode.xml");
}

function modeSelector(param, data, slot)
{
	if (!playerEngineRunning) return;
	trace("modeSelector: "+param);
	var mode:String;
	if (param.indexOf("mode1spot")>-1)
	{
		mode="sync";
	}
	else if (param.indexOf("mode2spot")>-1)
	{
		mode="audio";
	}
	else if (param.indexOf("mode3spot")>-1)
	{
		mode="text";
	}

	Packages.components.Reader.switchMode(mode);

	if (mode!=currentPlayMode)
	{
		switchMode(currentPlayMode, mode);
		currentPlayMode=mode;
	}
}

function switchMode(oldMode:String, newMode:String)
{
	trace("switchMode: "+oldMode+" "+newMode);
	var seekCount:Number;
	if (oldMode=="sync" || oldMode=="audio")
	{
		seekCount=applications.prototype.Logic.run("Count");
	}
	else if (oldMode=="text")
	{
		seekCount=accessTxtDisplay2SyncCount();
		var backIcon=mlf.gatekeeper.native.Caller.scanElement("Player", "backIcon");
		backIcon._visible=false;
		var stopIcon=mlf.gatekeeper.native.Caller.scanElement("Player", "stopIcon");
		stopIcon._visible=true;
	}
	trace("seekCount: "+seekCount);

	var mode=new Object();
	if (newMode=="sync")
	{
		mode.filterLayer="100";
	}
	else if (newMode=="audio")
	{
		mode.filterLayer="5";
	}
	else if (newMode=="text")
	{
		mode.filterLayer="10";
		var backIcon=mlf.gatekeeper.native.Caller.scanElement("Player", "backIcon");
		backIcon._visible=true;
		var stopIcon=mlf.gatekeeper.native.Caller.scanElement("Player", "stopIcon");
		stopIcon._visible=false;
	}
	applications.prototype.Logic.run("Mode", mode);
	applications.prototype.Logic.run("Seek", seekCount);

	if (newMode=="text") applications.prototype.Logic.run("Pause");
	else if (oldMode=="text") applications.prototype.Logic.run("Play");
}

function accessTxtDisplay2SyncCount()
{
	var container=mlf.gatekeeper.native.Caller.scanElement("Player", "txtReader");
	var txtReader=container.test.MLV.txtreader;
	var txtSync=container.test.MLV.txtsync;
	return txtSync.txtTimer.accessSyncByBlockNum(txtReader.txtResolver.accessCurrentBlockNum());
}

function format()
{
	trace(this._name+".format...");
	var playFormatLayer=mlf.gatekeeper.native.Caller.scanElement("PlayFormat", "basic");
	if (playFormatLayer==null)
	{
		establishPlayFormat();
	}
	changeFloatingVisible("PlayFormat");
}

function establishPlayFormat()
{
	// mlf.gatekeeper.native.Caller.MLoader("app/PlayFormat.xml");
	var fontArr=TextField.getFontList();
	// trace("fontArr: "+fontArr);
	localChineseFontArr=filterChineseFont(fontArr);
	localFontCount=0;
	// trace("fontArr: "+fontArr);
	for (var i=0; i<localChineseFontArr.length; i++)
	{
		var currentFontItem:String="";
		currentFontItem+="<moonlight name='PlayFormat' template='PlayFormat-ffcontainer' uri='app/PlayFormat_template.xml' dictionary='app/dic/playformat.xml'><portlet name='font"+i+"' style='no'>";
		currentFontItem+="<textfield name='tf"+i+"' selectable='no' height='18'>"+localChineseFontArr[i]+"</textfield>";
		currentFontItem+="<hotspot name='"+i+"' alpha='0' width='80' height='18'/>";
		currentFontItem+="<handler ins='PlayFormat-"+i+"' type='onPress' value='spot' src='lib:notes.components.ReadingPlayer.selectFontFamily'/>";
		currentFontItem+="<handler ins='PlayFormat-font"+i+"' type='onMLInit' value='PlayFormat' src='lib:notes.components.ReadingPlayer.initTF'/>";
		currentFontItem+="</portlet></moonlight>";
		mlf.gatekeeper.native.Caller.MLoader(null, null, null, null, currentFontItem);
	}
}

function selectFontFamily(param)
{
	// trace("selectFontFamily: "+param);
	var eleArr=param.split("-");
	var fontArrNum=Number(eleArr[eleArr.length-1]);
	var fontTf=mlf.gatekeeper.native.Caller.scanElement("PlayFormat", "fontInput");
	fontTf.text=localChineseFontArr[fontArrNum];
}

function initTF(param, data, slot)
{
	localFontCount++;
	if (localFontCount==localChineseFontArr.length)
	{
		var fontFormat=new TextFormat();
		for (var i=0; i<localChineseFontArr.length; i++)
		{
			var tf_display=mlf.gatekeeper.native.Caller.scanElement("PlayFormat", "tf"+i);
			fontFormat.font=tf_display.text;
			tf_display.setTextFormat(fontFormat);
		}
		
	}
}

function filterChineseFont(fontArr):Array
{
	var filteredArray:Array=new Array();
	for (var i=0; i<fontArr.length; i++)
	{
		if (fontArr[i].charAt(0)>"Z")
		{
			filteredArray.push(fontArr[i]);
		}
	}

	return filteredArray;
}

function applyFormat(param, data, slot)
{
	var currentTextFmtObj=new Object();
	// if (data.size!="") fmtObj.size=Number(data.size);
	currentTextFmtObj.size=Number(mlf.gatekeeper.native.Caller.scanElement(slot, "sizeInput").text);
	// if (data.color!="") fmtObj.color=Number(data.color);
	currentTextFmtObj.color=Number(mlf.gatekeeper.native.Caller.scanElement(slot, "colorInput").text);
	// if (data.lead!="") fmtObj.leading=Number(data.lead);
	currentTextFmtObj.leading=Number(mlf.gatekeeper.native.Caller.scanElement(slot, "leadInput").text);
	currentTextFmtObj.font=mlf.gatekeeper.native.Caller.scanElement(slot, "fontInput").text
	var container=mlf.gatekeeper.native.Caller.scanElement("Player", "txtReader");
	var txtResolver=container.test.MLV.txtreader.txtResolver;
	txtResolver.changeDisplayFormat({currentTextFormat:currentTextFmtObj});
}

function seek()
{
	trace(this._name+".seek...");
	var playSeekLayer=mlf.gatekeeper.native.Caller.scanElement("PlaySeek", "basic");
	if (playSeekLayer==null)
	{
		establishPlaySeek();
	}
	changeFloatingVisible("PlaySeek");
}

function establishPlaySeek()
{
	mlf.gatekeeper.native.Caller.MLoader("app/PlaySeek.xml");
}

function applyProgress(param, data, slot)
{
	var seekNum=Number(mlf.gatekeeper.native.Caller.scanElement(slot, "seekInput").text);
	if (seekNum>=0 && seekNum<100)
	{
		var duration=applications.prototype.Logic.run("Duration");
		trace("Seek: "+Math.floor(duration*seekNum/100));
		applications.prototype.Logic.run("Seek", Math.floor(duration*seekNum/100));
	}
}

function playlist()
{
	trace(this._name+".playlist...");
	var playlistLayer=mlf.gatekeeper.native.Caller.scanElement("PlayList", "basic");
	if (playlistLayer==null)
	{
		// establish play list by template according to UserProfile
		// now using Packages.task.Composition.readingWork object
		establishPlayListbyTemplate();
	}
	changeFloatingVisible("PlayList");
}

function establishPlayListbyTemplate()
{
	for (var i=0; i<playItemList.length; i++)
	{
		var currentPlayItem:String="";
		currentPlayItem+="<moonlight name='PlayList' template='PlayList-container' uri='app/Playlist_template.xml'><portlet name='item"+i+"' style='no'>";
		currentPlayItem+="<textfield name='rn"+i+"' selectable='no' height='30' html='true'>"+playItemList[i].name+"</textfield>";
		currentPlayItem+="<hotspot name='"+i+"' alpha='0' width='200' height='30'/>";
		currentPlayItem+="<handler ins='PlayList-"+i+"' type='onPress' value='spot' src='lib:notes.components.ReadingPlayer.pressPlayItem'/>";
		currentPlayItem+="<handler ins='PlayList-"+i+"' type='onRelease' value='spot' src='lib:notes.components.ReadingPlayer.releasePlayItem'/>";
		currentPlayItem+="<handler ins='PlayList-"+i+"' type='onRollOver' value='spot' src='lib:notes.components.ReadingPlayer.rolloverPlayItem'/>";
		currentPlayItem+="<handler ins='PlayList-"+i+"' type='onRollOut' value='spot' src='lib:notes.components.ReadingPlayer.rolloutPlayItem'/>";
		currentPlayItem+="<handler ins='PlayList-"+i+"' type='onReleaseOutside' value='spot' src='lib:notes.components.ReadingPlayer.rolloutPlayItem'/>";
		currentPlayItem+="</portlet></moonlight>";
		mlf.gatekeeper.native.Caller.MLoader(null, null, null, null, currentPlayItem);
	}
}

function pressPlayItem(param, data, slot)
{
	// trace("pressPlayItem: "+param+" "+slot);
	// if (selectedPlayItem==param) return;
	Packages.system.Platform.highlightBG(mlf.mcmanager.PathResolver.extractPath(param)._parent, mlf.gatekeeper.native.Caller.scanElement(slot, "@selectedBg"), 100);
}

function rolloverPlayItem(param, data, slot)
{
	// trace("rolloverPlayItem: "+param+" "+slot);
	// if (selectedPlayItem==param) return;
	Packages.system.Platform.highlightBG(mlf.mcmanager.PathResolver.extractPath(param)._parent, mlf.gatekeeper.native.Caller.scanElement(slot, "@overBg"), 50);
}

function rolloutPlayItem(param, data, slot)
{
	// if (selectedPlayItem==param) return;
	Packages.system.Platform.highlightBG(mlf.mcmanager.PathResolver.extractPath(param)._parent, mlf.gatekeeper.native.Caller.scanElement(slot, "@overBg"), 0);
}

function releasePlayItem(param, data, slot)
{
	// trace("releasePlayItem: "+param+" "+slot);
	// trace("releaseItem.param: "+param);
	// if (selectedPlayItem==param) return;
	rolloutPlayItem(param, data, slot);
	// selectedPlayItem=param;
	var eleArr=param.split("-");
	var playItemListNum=Number(eleArr[eleArr.length-1]);
	// playlistLayer._visible=false;
	// trace(applications.prototype.Logic.run("Status"));
	if (playItemList[playItemListNum].sync!=null)
	{
		currentPlayItemListNum=playItemListNum;
		if (applications.prototype.Logic.run("Status")==null)
		{
			openItem(playItemList[playItemListNum].sync);
		}
		else 
		{
			Packages.system.MLF.addListener("onPlayback", this);
			applications.prototype.Logic.run("Stop");
		}		
	}
}

function mSeek(param, data, slot)
{
	var num=Math.floor(data.pos/previewFillingMaskBar._width*applications.prototype.Logic.run("Duration"));
	 applications.prototype.Logic.run("Seek", num);
}

function mStop()
{
	applications.prototype.Logic.run("Stop");
}

function onPlayback(obj)
{
	trace("onPlayback: "+obj.param.type);
	if (obj.param.type=="playback")
	{
		
		var duration=applications.prototype.Logic.run("Duration");
		if (obj.param.param==2)
		{
			pressMenu("_root-Player-main-nowplaySpot", null, "Player");
			releaseMenu("_root-Player-main-nowplaySpot", null, "Player");
			 Packages.system.Platform.messageHint("Player", "", "normal");	//
		}
		previewFillingMaskBar._x=obj.param.param/duration*previewFillingMaskBar._width-previewFillingMaskBar._width+60;
		displayTimePeriod(timeDisplay, Number(obj.param.param), Number(duration));

	}
	else if (obj.param.type=="progress")
	{
		 Packages.system.Platform.messageHint("Player", Packages.system.MLF.scanDictionary(previewFillingMaskBar, "progress"), "warning");	//
	}
	else if (obj.param.type=="overPlay")
	{
		Packages.system.MLF.removeListener("onPlayback", this);
		playerEngineRunning=false;
		pressMenu("_root-Player-main-playlistSpot", null, "Player");
		releaseMenu("_root-Player-main-playlistSpot", null, "Player");
		var nextNum=currentPlayItemListNum+1;
		if (playItemList[currentPlayItemListNum+1]!=null)
		{
			/*openItem(playItemList[currentPlayItemListNum+1].sync);
			currentPlayItemListNum++;*/
			
			var path="_root-PlayList-basic-container-item"+nextNum+"-"+nextNum;
			pressPlayItem(path, null, "PlayList");
			releasePlayItem(path, null, "PlayList");
		}
		var playIcon=mlf.gatekeeper.native.Caller.scanElement("Player", "playIcon");
		playIcon._visible=true;
		var pauseIcon=mlf.gatekeeper.native.Caller.scanElement("Player", "pauseIcon");
		pauseIcon._visible=false;
		 Packages.system.Platform.messageHint("Player", "", "normal");	//
	}
	else if (obj.param.type=="readyPlay")
	{
		playerEngineRunning=true;
		var playIcon=mlf.gatekeeper.native.Caller.scanElement("Player", "playIcon");
		playIcon._visible=false;
		var pauseIcon=mlf.gatekeeper.native.Caller.scanElement("Player", "pauseIcon");
		pauseIcon._visible=true;
		 Packages.system.Platform.messageHint("Player", Packages.system.MLF.scanDictionary(playIcon, "readyPlay"), "hint");	//
	}
	else if (obj.param.type=="stopPlay")
	{
		var playIcon=mlf.gatekeeper.native.Caller.scanElement("Player", "playIcon");
		playIcon._visible=true;
		var pauseIcon=mlf.gatekeeper.native.Caller.scanElement("Player", "pauseIcon");
		pauseIcon._visible=false;
		 Packages.system.Platform.messageHint("Player", Packages.system.MLF.scanDictionary(playIcon, "stopPlay"), "warning");	//
	}
	else if (obj.param.type=="startPlay")
	{
		var playIcon=mlf.gatekeeper.native.Caller.scanElement("Player", "playIcon");
		playIcon._visible=false;
		var pauseIcon=mlf.gatekeeper.native.Caller.scanElement("Player", "pauseIcon");
		pauseIcon._visible=true;
		// Packages.system.Platform.messageHint("Player", Packages.system.MLF.scanDictionary(playIcon, "startPlay"), "hint");	//
		Packages.system.Platform.messageHint("Player", "", "normal");	//
	}
}

function openItem(syncURI:String)
{
	// var sourceMLV=generateMLVbyWork();
	var playArea=mlf.gatekeeper.native.Caller.scanElement("Player", "txtReader");
	trace("playArea: "+playArea);

	var param=new Object();
	param.target=playArea;
		
	param.type="uri";
	param.source=syncURI;
	Packages.system.MLF.addListener("onPlayback", this);

	trace(applications.prototype.Logic.run("Version"));
	applications.prototype.Logic.run("Open", param);
}

function pressMenu(param, data, slot)
{
	if (selectedMenu==param) return;
	if (playerEngineRunning || param.indexOf("nowplay")>-1 || param.indexOf("playlist")>-1)
	{
	Packages.system.Platform.highlightBG(mlf.mcmanager.PathResolver.extractPath(param), mlf.gatekeeper.native.Caller.scanElement(slot, "selectedBg"), 100);	
	}
}

function rolloverMenu(param, data, slot)
{
	if (selectedMenu==param) return;
	if (playerEngineRunning || param.indexOf("nowplay")>-1 || param.indexOf("playlist")>-1)
	{
	Packages.system.Platform.highlightBG(mlf.mcmanager.PathResolver.extractPath(param), mlf.gatekeeper.native.Caller.scanElement(slot, "overBg"), 50);
	}
}

function rolloutMenu(param, data, slot)
{
	if (selectedMenu==param) return;
	if (playerEngineRunning || param.indexOf("nowplay")>-1 || param.indexOf("playlist")>-1)
	{
	Packages.system.Platform.highlightBG(mlf.mcmanager.PathResolver.extractPath(param), mlf.gatekeeper.native.Caller.scanElement(slot, "overBg"), 0);
	}
}

function releaseMenu(param, data, slot)
{
	if (selectedMenu==param) return;
	if (playerEngineRunning || param.indexOf("nowplay")>-1 || param.indexOf("playlist")>-1)
	{
	rolloutMenu(param, data, slot);
	selectedMenu=param;
	if (param.indexOf("playlist")>-1)
	{
		playlist();
		changeResolverTf(250, 460);
	}
	else if (param.indexOf("mode")>-1)
	{
		mode();
		changeResolverTf(250, 460);
	}
	else if (param.indexOf("format")>-1)
	{
		format();
		changeResolverTf(250, 460);
	}
	else if (param.indexOf("seek")>-1)
	{
		seek();
		changeResolverTf(250, 460);
	}
	else if (param.indexOf("nowplay")>-1)
	{
		nowplay();
		changeResolverTf(50, 660);
	}
	}
}

function changeResolverTf(x:Number, width:Number)
{
	var txtResolver=mlf.gatekeeper.native.Caller.scanElement("Player", "txtReader");
	txtResolver._x=x;
	txtResolver._width=width;
}

function nowplay()
{
	changeFloatingVisible();
}

function displayTimePeriod(display_tf:TextField, progress:Number, duration:Number)
{
	display_tf.text=calculateTimeFormat(progress)+" / "+calculateTimeFormat(duration);
}

function calculateTimeSecond(tformat:String):Number
{
	var tEleArr=tformat.split(":");
	var totalSeconds=Number(tEleArr[2])+Number(tEleArr[1])*60+Number(tEleArr[0])*3600;
	// trace("totalSeconds: "+totalSeconds);
	return totalSeconds;
}

function calculateTimeFormat(seconds:Number):String
{
	var result:String="";

	var hour=Math.floor(seconds/3600);
	if (hour.toString().length==1)
	{
		result="0"+hour;
	}
	else result=hour;
	var minute=Math.floor((seconds-hour*3600)/60);
	if (minute.toString().length==1)
	{
		result+=":0"+minute;
	}
	else result+=":"+minute;
	var second=Math.floor(seconds-hour*3600-minute*60);
	if (second.toString().length==1)
	{
		result+=":0"+second;
	}
	else result+=":"+second;

	return result;
}

function ctrl(param, data, slot)
{
	trace("ctrl.param: "+param);
	if (!playerEngineRunning) return;
	if (currentPlayMode=="sync" || currentPlayMode=="audio")
	{
		if (param.indexOf("1")>-1)
		{
			if (applications.prototype.Logic.run("Status")=="play")
			{
				applications.prototype.Logic.run("Pause");
			}
			else applications.prototype.Logic.run("Play");
		}
		else applications.prototype.Logic.run("Stop");
	}
	else if (currentPlayMode=="text")
	{
		if (param.indexOf("1")>-1)
		{
			mlf.mcmanager.MessageAgent.getMessageDispatcher().dispatch({type:"onTxtSync", offset:1});
		}
		else mlf.mcmanager.MessageAgent.getMessageDispatcher().dispatch({type:"onTxtSync", offset:-1});

		// var display_tf=_root.Player.main.txtReader.test.MLV["5"].chapter_c1_c1.displayContent;
		// display_tf.scroll=0;
	}
}

function pressMode(param, data, slot)
{
	if (selectedMode==param) return;
	Packages.system.Platform.highlightBG(mlf.mcmanager.PathResolver.extractPath(param), mlf.gatekeeper.native.Caller.scanElement(slot, "selectedBg"), 100);	
}

function rolloverMode(param, data, slot)
{
	if (selectedMode==param) return;
	Packages.system.Platform.highlightBG(mlf.mcmanager.PathResolver.extractPath(param), mlf.gatekeeper.native.Caller.scanElement(slot, "overBg"), 50);
}

function rolloutMode(param, data, slot)
{
	if (selectedMode==param) return;
	Packages.system.Platform.highlightBG(mlf.mcmanager.PathResolver.extractPath(param), mlf.gatekeeper.native.Caller.scanElement(slot, "overBg"), 0);
}

function releaseMode(param, data, slot)
{
	if (selectedMode==param) return;
	rolloutMenu(param, data, slot);
	selectedMode=param;
	modeSelector(param, data, slot);
}

function pressApply(param, data, slot)
{
	Packages.system.Platform.highlightBG(mlf.mcmanager.PathResolver.extractPath(param), mlf.gatekeeper.native.Caller.scanElement(slot, "highlightBg"), 100);	
}

function rolloverApply(param, data, slot)
{
	Packages.system.Platform.highlightBG(mlf.mcmanager.PathResolver.extractPath(param), mlf.gatekeeper.native.Caller.scanElement(slot, "highlightBg"), 50);
}

function rolloutApply(param, data, slot)
{
	Packages.system.Platform.highlightBG(mlf.mcmanager.PathResolver.extractPath(param), mlf.gatekeeper.native.Caller.scanElement(slot, "highlightBg"), 0);
}

function releaseApply(param, data, slot)
{
	rolloutSeek(param, data, slot);
	if (slot=="PlaySeek")
	{
		applyProgress(param, data, slot)
	}
	else if (slot=="PlayFormat")
	{
		applyFormat(param, data, slot);
	}
}